package com.atguigu.gulimall.member.web;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.atguigu.common.utils.R;
import com.atguigu.gulimall.member.feign.OrderFeignService;
import com.netflix.client.http.HttpRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Controller
public class MemberWebController {

    @Autowired
    OrderFeignService orderFeignService;

    @GetMapping("/memberOrder.html")
    public String memberPage(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum, Model model, HttpServletRequest request){

        //获取到支付宝给我们的签名
        //验证签名

        Map<String, Object> map = new HashMap();
        map.put("pageNum",pageNum);
        R r = orderFeignService.listWithItem(map);
        if(r.getCode()==0){
            log.info(JSON.toJSONString(r));
            model.addAttribute("orders",r);
        }
        return "index";
    }
}
